import request from "../../utils/request";

// 获取用户信息

const getUserInfo = ()=>{
    return request.get('/api/user')
}

// 更改用户信息
const changeUserInfo = (userName)=>{
    return request.put('/api/user',{name:userName})
}

// 修改用户头像

const changeUserAvatar = (imgUrl)=>{
    return request.patch('/api/user/avatar',{avatar:imgUrl})
}

// 获取地址列表

const getAddressList = ()=>{
    return request.get('/api/address')
}

// 添加收货地址
const addAddress = (addressInfo)=>{
    return request.post('/api/address',addressInfo)
}

// 删除收货地址
const deleteAddress = (addressID)=>{
    return request.delete(`/api/address/${addressID}`)
}

// 修改收货地址

const changeAddress = (addressID,addressInfo)=>{
    return request.put(`/api/address/${addressID}`,addressInfo)
}

// 获取地址详情

const  getAddressDetail = (addressID)=>{
    return request({
        url:`/api/address/${addressID}`,
        method:'get',
    })
}
// 获取收藏
const getAllCollection = (page)=>{
    return request.get('/api/collects',{params:{page:page}})
}
export {
    getUserInfo,
    changeUserInfo,
    changeUserAvatar,
    getAddressList,
    addAddress,
    deleteAddress,
    changeAddress,
    getAddressDetail,
    getAllCollection
}